Class Event

  • Direct Known Subclasses:
    Concert, TVShow

    public class Event
    extends java.lang.Object
    represents a generic event of an artist in a certain venue on certain date
    Since:
    ExerciseSheet02
    Version:
    3
    Author:
    Jonas Altrock (ew20b126@technikum-wien.at)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Artist artist
      the artist who appeared at this event the artist of an event cannot be null
      private int attendees
      the number of attendees of this event.
      private Date date
      the date on which this event takes place
      private java.lang.String description
      description of this event
      private Venue venue
      the venue at which this event takes place
    • Constructor Summary

      Constructors 
      Constructor Description
      Event()
      creates a default event
      Event​(Event e)
      creates a deep copy of an event
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Artist getArtist()
      gets the artist of this event
      int getAttendees()
      gets the number of attendees of this event
      Date getDate()
      gets the date of this event
      java.lang.String getDescription()
      gets the description of this event
      Venue getVenue()
      gets the venue of this event
      int impact()
      returns the impact of this event
      void setArtist​(Artist artist)
      sets the artist of this event
      void setAttendees​(int attendees)
      sets the number of attendees of this event
      void setDate​(Date date)
      sets the date of this event
      void setDescription​(java.lang.String description)
      sets the description of this event
      void setVenue​(Venue venue)
      sets the venue of this event
      java.lang.String toString()
      returns a String representation of this event
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • artist

        private Artist artist
        the artist who appeared at this event the artist of an event cannot be null
      • attendees

        private int attendees
        the number of attendees of this event.
      • date

        private Date date
        the date on which this event takes place

        a null date represents an unknown date

      • description

        private java.lang.String description
        description of this event

        default description is an empty String

      • venue

        private Venue venue
        the venue at which this event takes place

        a null venue represents an unknown venue

    • Constructor Detail

      • Event

        public Event()
        creates a default event

        a default event has a default artist and an empty description. all other information is unknown (See docu for fields)

      • Event

        public Event​(Event e)
        creates a deep copy of an event
        Parameters:
        e - the event to copy
    • Method Detail

      • getArtist

        public Artist getArtist()
        gets the artist of this event
        Returns:
        the artist
      • setArtist

        public void setArtist​(Artist artist)
        sets the artist of this event

        the artist of an event cannot be null

        Parameters:
        artist - the artist to set
      • getAttendees

        public int getAttendees()
        gets the number of attendees of this event
        Returns:
        the attendees
      • setAttendees

        public void setAttendees​(int attendees)
        sets the number of attendees of this event

        the number of attendees must be a non-negative number. When called with invalid arguments this event remains unchanged.

        Parameters:
        attendees - the attendees to set
      • getDate

        public Date getDate()
        gets the date of this event

        this method is defensive in the sense that it returns a copy of the date

        Returns:
        the date
      • setDate

        public void setDate​(Date date)
        sets the date of this event

        an unknown date is represented by a null date. this method is defensive in the sense that this event keep a copy of the original date

        Parameters:
        date - the date to set
      • getDescription

        public java.lang.String getDescription()
        gets the description of this event
        Returns:
        the description
      • setDescription

        public void setDescription​(java.lang.String description)
        sets the description of this event

        description can not be null

        Parameters:
        description - the description to set
      • getVenue

        public Venue getVenue()
        gets the venue of this event
        Returns:
        the Venue
      • setVenue

        public void setVenue​(Venue venue)
        sets the venue of this event
        Parameters:
        venue - the venue to set
      • toString

        public java.lang.String toString()
        returns a String representation of this event

        the string representation of an event is (without quotes, but including line breaks):

         "artist" @ "venue name" on "date"
         "description"
         ("attendees" attending ("impact"))
         

        if a value is not available, replace it with "unknown"

        Overrides:
        toString in class java.lang.Object
        Returns:
        a String representation of this event
      • impact

        public int impact()
        returns the impact of this event

        the impact is an estimation of the number of people who took notice of this event for a generic event, the impact is the number of attendees times 2.

        Returns:
        the impact